package com.zyx;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

public class AppDemo {
    public static void main(String[] args) throws IOException {
        //加载mybatis核心的配置文件
        InputStream is = Resources.getResourceAsStream("mybatis-conf.xml");
        //建立SqlSessionFactory工具类
        SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(is);
        //建立SqlSession
        SqlSession ss = sf.openSession();

        //执行相关的语句
        //查看所有数据库
        System.out.println(ss.selectList("dbs"));
        //查看数据库版本号
        System.out.println(ss.selectOne("ver", String.class).toString());
        System.out.println(ss.selectList("tbs"));
        System.out.println(ss.selectList("tbs", "mysql"));
        System.out.println(ss.selectMap("shows",""));
    }
}
